<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:composite="http://java.sun.com/jsf/composite"
	xmlns:common="http://java.sun.com/jsf/composite/common">

<composite:interface>
	<composite:attribute name="ordenProd"></composite:attribute>
	<composite:attribute name="readOnly" default="true"></composite:attribute>
	<composite:facet name="extrusionWork"></composite:facet>
	<composite:facet name="impresionWork"></composite:facet>
	<composite:facet name="confectionWork"></composite:facet>
	<composite:attribute name="showWorkPanels" default="false"></composite:attribute>
</composite:interface>

<composite:implementation>
	<div id="#{cc.clientId}">
		<p:dialog id="dialog" header="Maquina de extrusion" widgetVar="dlg"
			resizable="true" modal="true">
			<p:ajax event="close" listener="#{prodSpecMB.maquinaDialogClosed}"
				update="codigoMaquina" />
			<common:maquinas selectButtonAction="dlg.hide();" maqTipo="1"
				id="maquinas" selectButtonRendered="true">
			</common:maquinas>
		</p:dialog>
		<p:dialog id="impMaquinaDialog" header="Maquina de impresion"
			widgetVar="impDlg" resizable="true" modal="true">
			<p:ajax event="close" listener="#{prodSpecMB.impMaquinaDialogClosed}"
				update="impCodigoMaquina" />
			<common:maquinas selectButtonAction="impDlg.hide();" maqTipo="2"
				id="impMaquinas" selectButtonRendered="true">
			</common:maquinas>
		</p:dialog>
		<p:dialog id="confMaquinaDialog" header="Maquina de confeccion"
			widgetVar="confDlg" resizable="true" modal="true">
			<p:ajax event="close"
				listener="#{prodSpecMB.confMaquinaDialogClosed}"
				update="confCodigoMaquina" />
			<common:maquinas selectButtonAction="confDlg.hide();" maqTipo="3"
				id="confMaquinas" selectButtonRendered="true">
			</common:maquinas>
		</p:dialog>
		<div class="panel panel-default">
			<div class="panel-heading">
				<p:outputLabel value="Datos del pedido"></p:outputLabel>
			</div>
			<div class="panel-body"></div>
			<table class="table table-bordered table-striped">
				<tr>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Fecha">
						</h:outputText></td>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Pedido"></h:outputText></td>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Cliente"></h:outputText></td>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Fecha de Entrega">
						</h:outputText></td>
				</tr>
				<tr>
					<td><h:outputText
							value="#{cc.attributes.ordenProd.fechaCreacion}">
							<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
						</h:outputText></td>
					<td><h:outputText value="#{cc.attributes.ordenProd.id}"></h:outputText>
					</td>
					<td><h:outputText
							value="#{cc.attributes.ordenProd.pedidoVenta.clienteBean.nombre}"></h:outputText>
					</td>
					<td><h:outputText
							value="#{cc.attributes.ordenProd.fechaEntrega}">
							<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
						</h:outputText></td>
				</tr>
			</table>
		</div>
		<div class="panel panel-default">
			<div class="panel-heading">
				<p:outputLabel value="Extrusion"></p:outputLabel>
				<p:spacer width="10"></p:spacer>
				<h:outputText styleClass="text-success" style="font-weight:bold;"
					value="Terminado"
					rendered="#{cc.attributes.ordenProd.extrusion.finalizationDate != null}">
				</h:outputText>
				<p:spacer width="5"></p:spacer>
				<h:outputText styleClass="text-success" style="font-weight:bold;"
					value="#{cc.attributes.ordenProd.extrusion.finalizationDate}"
					rendered="#{cc.attributes.ordenProd.extrusion.finalizationDate != null}">
					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
				</h:outputText>
			</div>
			<div class="panel-body">
				<table class="table table-bordered table-striped">
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Fecha Inicio: "></h:outputText> <p:inplace
								id="fechaInicioInplace" editor="true" styleClass="text-info"
								emptyLabel="Modificar">
								<p:ajax listener="#{prodSpecMB.extFechaIniSelected}"
									update="fechaFinInplace" event="save"></p:ajax>
								<p:calendar
									value="#{cc.attributes.ordenProd.extrusion.fechaInicio}"
									pattern="dd/MM/yyyy HH:mm" styleClass="smallCalendar"
									mindate="#{prodSpecMB.currentDate}" id="startDateCal"
									showOn="button" required="true">
									<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
								</p:calendar>
							</p:inplace></td>
						<td><p:outputLabel
								style="font-weight: bold; float: left; width: 120px; margin-left:7px;"
								value="Maquina:" styleClass="pull-left"></p:outputLabel> <h:outputText
								styleClass="pull-left"
								value="#{cc.attributes.ordenProd.extrusion.maquina.maqCodigo}"
								id="codigoMaquina"></h:outputText> <a
							class="btn btn-small pull-right" href="#" onclick="dlg.show();"><span
								class="glyphicon glyphicon-cog"></span></a></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Fecha Final: "></h:outputText> <p:inplace
								id="fechaFinInplace" editor="true" styleClass="text-info"
								emptyLabel="Modificar">
								<p:ajax event="save"
									listener="#{prodSpecMB.extrusionFechaFinSelected}"
									update="#{cc.attributes.ordenProd.item.impresion ? 
								'impFechaInicioInplace impCodigoMaquina' : 'confFechaInicioInplace confCodigoMaquina'}" />
								<p:calendar
									value="#{cc.attributes.ordenProd.extrusion.fechaFin}"
									pattern="dd/MM/yyyy HH:mm" styleClass="smallCalendar"
									mindate="#{prodSpecMB.currentDate}" id="endDateCal"
									showOn="button">
									<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
								</p:calendar>
							</p:inplace></td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Ancho: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.item.ancho}"></h:outputText></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Largo: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.item.largo}"></h:outputText></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Espesor: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.item.espesor}"></h:outputText>
						</td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Gramos x m2: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.extrusion.grm2}">
								<f:convertNumber maxFractionDigits="2"></f:convertNumber>
							</h:outputText></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Gramaje: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.extrusion.gramaje}">
								<f:convertNumber maxFractionDigits="2"></f:convertNumber>
							</h:outputText></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="PB: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.extrusion.pesoBolsa}">
								<f:convertNumber maxFractionDigits="2"></f:convertNumber>
							</h:outputText></td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Tipo de bolsa: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.item.itemTipo.descripcion}"></h:outputText>
						</td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Tipo de material: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.item.densidad}"
								converter="DensidadConverter"></h:outputText></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Tratado: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.item.tratado}"></h:outputText>
						</td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Metros: " for="metrosInplace"></h:outputText> <p:inplace
								id="metrosInplace" editor="true" styleClass="text-info"
								emptyLabel="Modificar">
								<p:ajax event="save" update="kilosValue" />
								<p:inputText value="#{cc.attributes.ordenProd.extrusion.metros}"
									style="width:90px;" required="true">
									<f:convertNumber maxFractionDigits="2"></f:convertNumber>
								</p:inputText>
							</p:inplace></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Bobinas: "></h:outputText> <p:inplace id="bobinasInplace"
								editor="true" styleClass="text-info" emptyLabel="Modificar">
								<p:inputText style="width:90px;"
									value="#{cc.attributes.ordenProd.extrusion.bobinas}"
									required="true"></p:inputText>
							</p:inplace></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Kilos: "></h:outputText> <h:outputText id="kilosValue"
								value="#{cc.attributes.ordenProd.extrusion.kilos}">
								<f:convertNumber maxFractionDigits="2"></f:convertNumber>
							</h:outputText></td>
					</tr>
				</table>
			</div>

			<p:tabView id="extrusionTabs" dynamic="true" cache="true"
				styleClass="">
				<p:tab id="prodTab" title="PRODUCCION"
					rendered="#{cc.attributes.showWorkPanels}">
					<ui:include src="/pages/produccion/extrusionWorkTable.xhtml"></ui:include>
				</p:tab>
				<p:tab id="formulaTab" title="FORMULA">
					<common:formulaPanel ordenProd="#{cc.attributes.ordenProd}"
						saveFormulaListner="#{ordenProdMB.saveFormula}"
						saveAsNewFormulaListner="#{ordenProdMB.saveAsNewFormula}"></common:formulaPanel>
				</p:tab>
			</p:tabView>
		</div>
	</div>
	<h:panelGroup rendered="#{cc.attributes.ordenProd.item.impresion}"
		layout="block">
		<div class="panel panel-default">
			<div class="panel-heading">
				<p:outputLabel value="Impresion"></p:outputLabel>
				<p:spacer width="10"></p:spacer>
				<h:outputText styleClass="text-success" style="font-weight:bold;"
					value="Terminado"
					rendered="#{cc.attributes.ordenProd.impresions.finalizationDate != null}">
				</h:outputText>
				<p:spacer width="5"></p:spacer>
				<h:outputText styleClass="text-success" style="font-weight:bold;"
					value="#{cc.attributes.ordenProd.impresions.finalizationDate}"
					rendered="#{cc.attributes.ordenProd.impresions.finalizationDate != null}">
					<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
				</h:outputText>
			</div>
			<div class="panel-body">
				<table class="table table-bordered table-striped">
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Fecha Inicio: "></h:outputText> <p:inplace
								id="impFechaInicioInplace" editor="true" styleClass="text-info"
								emptyLabel="Modificar">
								<p:ajax listener="#{prodSpecMB.impFechaIniSelected}"
									update="impFechaFinInplace" event="save"></p:ajax>
								<p:calendar
									value="#{cc.attributes.ordenProd.impresions.fechaInicio}"
									pattern="dd/MM/yyyy HH:mm" styleClass="smallCalendar"
									mindate="#{prodSpecMB.currentDate}" id="impStartDateCal"
									showOn="button" required="true">
									<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
								</p:calendar>
							</p:inplace></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Maquina: "></h:outputText> <h:outputText
								value="#{cc.attributes.ordenProd.impresions.maquina.maqCodigo}"
								id="impCodigoMaquina"></h:outputText> <a
							class="btn btn-small pull-right" href="#"
							onclick="impDlg.show();"><span
								class="glyphicon glyphicon-cog"></span></a></td>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Fecha Final: "></h:outputText> <p:inplace
								id="impFechaFinInplace" editor="true" styleClass="text-info"
								emptyLabel="Modificar">
								<p:ajax event="save"
									listener="#{prodSpecMB.impresionFechaFinSelected}"
									update="confStartDateCal confCodigoMaquina"></p:ajax>
								<p:calendar
									value="#{cc.attributes.ordenProd.impresions.fechaFin}"
									pattern="dd/MM/yyyy HH:mm" styleClass="smallCalendar"
									mindate="#{prodSpecMB.currentDate}" id="impEndDateCal"
									showOn="button">
									<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
								</p:calendar>
							</p:inplace></td>
					</tr>

					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Texto: "></h:outputText> <h:outputText id="text"
								value="#{cc.attributes.ordenProd.item.depItemPrintSpec.text}" />
						</td>
						<td rowspan="7" colspan="2" id="imagenId"><p:graphicImage
								value="#{muestrasMB.dynaImage}" width="300px">
								<f:param name="fileName"
									value="#{cc.attributes.ordenProd.item.muestraBean.fileName}"></f:param>
							</p:graphicImage></td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Color: "></h:outputText> <h:outputText id="colorid"
								value="#{cc.attributes.ordenProd.item.depItemPrintSpec.cantColor}" />
						</td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Cilindro: "></h:outputText> <h:outputText id="cilindroid"
								value="#{cc.attributes.ordenProd.item.depItemPrintSpec.cilindro}" />
						</td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Frente/Dorso: "></h:outputText> <h:outputText
								id="dorsoid"
								value="#{cc.attributes.ordenProd.item.depItemPrintSpec.frente ? 'Frente' : ''} #{cc.attributes.ordenProd.item.depItemPrintSpec.dorso ? 'Dorso' : ''}" />
						</td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Largo: "></h:outputText> <h:outputText id="largoid"
								value="#{cc.attributes.ordenProd.item.largo}" /></td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Cantidad: "></h:outputText> <h:outputText id="cantidadid"
								value="#{cc.attributes.ordenProd.cantidad}" /></td>
					</tr>
					<tr>
						<td><h:outputText
								style="font-weight: bold; float: left; width: 120px;"
								value="Tipo de bolsa: "></h:outputText> <h:outputText
								id="tipobolsaid"
								value="#{cc.attributes.ordenProd.item.itemTipo.descripcion}" />
						</td>
					</tr>
				</table>
			</div>
			<p:tabView id="impresionTabs" dynamic="true" cache="true"
				styleClass="">
				<p:tab id="prodTab" title="PRODUCCION"
					rendered="#{cc.attributes.showWorkPanels}">
					<ui:include src="/pages/produccion/impresionWorkTable.xhtml"></ui:include>
				</p:tab>
			</p:tabView>
		</div>
	</h:panelGroup>
	<div class="panel panel-default">
		<div class="panel-heading">
			<h:outputText value="Confeccón"></h:outputText>
			<p:spacer width="10"></p:spacer>
			<h:outputText styleClass="text-success" style="font-weight:bold;"
				value="Terminado"
				rendered="#{cc.attributes.ordenProd.confeccions.finalizationDate != null}">
			</h:outputText>
			<p:spacer width="5"></p:spacer>
			<h:outputText styleClass="text-success" style="font-weight:bold;"
				value="#{cc.attributes.ordenProd.confeccions.finalizationDate}"
				rendered="#{cc.attributes.ordenProd.confeccions.finalizationDate != null}">
				<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
			</h:outputText>
		</div>
		<div class="panel-body">
			<table class="table table-bordered table-striped">
				<tr>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Fecha Inicio: "></h:outputText> <p:inplace
							id="confFechaInicioInplace" editor="true" styleClass="text-info"
							emptyLabel="Modificar">
							<p:ajax listener="#{prodSpecMB.confFechaIniSelected}"
								update="confFechaFinInplace" event="save"></p:ajax>
							<p:calendar
								value="#{cc.attributes.ordenProd.confeccions.fechaInicio}"
								pattern="dd/MM/yyyy HH:mm" styleClass="smallCalendar"
								mindate="#{prodSpecMB.currentDate}" id="confStartDateCal"
								showOn="button" required="true">
								<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
							</p:calendar>
						</p:inplace></td>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Maquina: "></h:outputText> <h:outputText
							value="#{cc.attributes.ordenProd.confeccions.maquina.maqCodigo}"
							id="confCodigoMaquina"></h:outputText> <a
						class="btn btn-small pull-right" href="#"
						onclick="confDlg.show();"><span
							class="glyphicon glyphicon-cog"></span></a></td>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Fecha Final: "></h:outputText> <p:inplace
							id="confFechaFinInplace" editor="true" styleClass="text-info"
							emptyLabel="Modificar">
							<p:calendar
								value="#{cc.attributes.ordenProd.confeccions.fechaFin}"
								pattern="dd/MM/yyyy HH:mm" styleClass="smallCalendar"
								mindate="#{prodSpecMB.currentDate}" id="confEndDateCal"
								showOn="button">
								<f:convertDateTime pattern="dd/MM/yyyy HH:mm" />
							</p:calendar>
						</p:inplace></td>
				</tr>
				<tr>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Ancho: "></h:outputText> <h:outputText
							value="#{cc.attributes.ordenProd.item.ancho}"></h:outputText></td>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Largo: "></h:outputText> <h:outputText
							value="#{cc.attributes.ordenProd.item.largo}"></h:outputText></td>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Peso: "></h:outputText> <h:outputText
							value="#{gramaje * largo}">
							<f:convertNumber maxFractionDigits="2"></f:convertNumber>
						</h:outputText></td>
				</tr>
				<tr>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Cantidad: "></h:outputText> <h:outputText
							id="confeccionCant" value="#{cc.attributes.ordenProd.cantidad}" />
					</td>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Tipo de bolsa: "></h:outputText> <h:outputText
							id="confeccionTipoBolsaid"
							value="#{cc.attributes.ordenProd.item.itemTipo.descripcion}" />
					</td>
					<td><h:outputText
							style="font-weight: bold; float: left; width: 120px;"
							value="Tipo de material: "></h:outputText> <h:outputText
							value="#{cc.attributes.ordenProd.item.densidad}"
							converter="DensidadConverter">
						</h:outputText></td>
				</tr>
			</table>
		</div>
		<p:tabView id="confeccionTabs" dynamic="true" cache="true"
			styleClass="">
			<p:tab id="prodTab" title="PRODUCCION"
				rendered="#{cc.attributes.showWorkPanels}">
				<ui:include src="/pages/produccion/confeccionWorkTable.xhtml"></ui:include>
			</p:tab>
		</p:tabView>
	</div>
</composite:implementation>

</html>